(function() {
	$(".order_p2").on("click", function(e) {
		$(".order_inf").fadeIn();

		$(document).one("click", function() {
			$(".order_inf").fadeOut();
		});

		e.stopPropagation();
	});
	$(".order_p").on("click", function(e) {
		e.stopPropagation();
	});
	$("#o5_cof").on("click", function() {
		$(".order8_mask2").fadeIn();
	});
	$("#o8_mask2_d").on("click", function() {
		$(".order8_mask2").fadeOut();
		clear_photo();
	})
	$(".o8_pingjia").on("click",function(){
		window.location.href="../my_order/wodedingdan.html";
	})
	//*********评价系统 S*****************
	$("#xingxing1 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg1", "0");
	})
	$("#xingxing1 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg2", "1");
	})
	$("#xingxing1 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg3", "2");
	})
	$("#xingxing1 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg4", "3");
	})
	$("#xingxing1 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg5", "4");
	})
	$("#xingxing1 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg6", "5");
	})
	$("#xingxing1 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg7", "6");
	})
	$("#xingxing1 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg8", "7");
	})
	$("#xingxing1 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg9", "8");
	})
	$("#xingxing1 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg10", "9");
	})
	$("#xingxing2 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg1", "0");
	})
	$("#xingxing2 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg2", "1");
	})
	$("#xingxing2 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg3", "2");
	})
	$("#xingxing2 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg4", "3");
	})
	$("#xingxing2 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg5", "4");
	})
	$("#xingxing2 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg6", "5");
	})
	$("#xingxing2 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg7", "6");
	})
	$("#xingxing2 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg8", "7");
	})
	$("#xingxing2 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg9", "8");
	})
	$("#xingxing2 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg10", "9");
	})
	$("#xingxing3 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg1", "0");
	})
	$("#xingxing3 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg2", "1");
	})
	$("#xingxing3 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg3", "2");
	})
	$("#xingxing3 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg4", "3");
	})
	$("#xingxing3 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg5", "4");
	})
	$("#xingxing3 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg6", "5");
	})
	$("#xingxing3 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg7", "6");
	})
	$("#xingxing3 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg8", "7");
	})
	$("#xingxing3 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg9", "8");
	})
	$("#xingxing3 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg10", "9");
	})
	var pinjia_res=["半颗星","一颗星","一颗半星","两颗星","两颗半星","三颗星","三颗半星","四颗星","四颗半星","五颗星"];
	function dele_class(obj, stage, content) {
		//		console.log(obj.attr("class"))
		if(obj.hasClass("stytle1")) {
			var style_color = "stytle1 " + stage;
			$(".res1").html(pinjia_res[content]);
		} else if(obj.hasClass("stytle2")) {
			var style_color = "stytle2 " + stage;
			$(".res2").html(pinjia_res[content]);
		} else if(obj.hasClass("stytle3")) {
			var style_color = "stytle3 " + stage;
			$(".res3").html(pinjia_res[content]);
		}
		obj.attr("class", style_color);
	}
	//*********评价系统 E*****************
	/**************************上传图片 S**********************/
	$("input[type=file]").on("change", function() {
			for(var i = 1; i <= this.files.length; i++) {
				if($(".o8_img_up").length + i > 5) {
					$("#shanchuchenggong").text("上传图片已超过五张");
					$("#shanchu2").fadeIn();
					break;
				} else {
					$(".o8_photo_num1").html($(".o8_img_up").length + i);
					$(".o8_photo_num2").html(5 - ($(".o8_img_up").length + i));
				}
				var file = this.files[i - 1];
				if(!/image\/\w+/.test(file.type)) {
					$("#shanchuchenggong").text("请传入有效图片");
					$("#shanchu2").fadeIn();
				} else if(file.fileSize >= 5242880) {
					$("#shanchuchenggong").text("上传图片要小于5M");
					$("#shanchu2").fadeIn();
				} else {
					if($(".o8_img_up").length < 5) {
						if(window.FileReader) {
							var fr = new FileReader();
							fr.onloadend = function(e) {
								var imgs = "<span class='o8_img_up'><div class='o8_mask_dele'>删除</div><img src='" + e.target.result + "'/></span>";
								$(imgs).insertAfter($(".o8_img_click"));
								$(".o8_mask_dele").bind("click", function() {
									$(this).parent().remove();
									$(".o8_photo_num1").html($(".o8_img_up").length);
									$(".o8_photo_num2").html(5 - $(".o8_img_up").length);
								})
							};
							fr.readAsDataURL(file);
						}
					} else {
						$("#shanchuchenggong").text("上传图片已超过五张");
						$("#shanchu2").fadeIn();
					}
				}
			}
		})
		/**************************上传图片 E**********************/
		//*********评分系统关闭 S*****************
	function clear_photo() {
		setTimeout(function() {
			$("span").remove(".o8_img_up");
			var style_color1 = "stytle1 bg0";
			var style_color2 = "stytle2 bg0";
			var style_color3 = "stytle3 bg0";
			$(".res1").html("");
			$(".res2").html("");
			$(".res3").html("");
			$(".stytle1").attr("class", style_color1);
			$(".stytle2").attr("class", style_color2);
			$(".stytle3").attr("class", style_color3);
			$(".order8_mask2 textarea").val("");
			$(".order8_mask2 .o8_num span").html("0");
		}, 500)
	}
	//*********评分系统关闭 S*****************
	//*********评价系统 E*****************

	$(".o8_pingjia").on("click", function() {
			$(".order8_mask2").fadeOut();
			clear_photo();
		})
	
	$(function(){
		var i=0,
		textarea=$("textarea"),
		zishu=$(".o8_num span"),
		area_val="";
			textarea.on("keyup",function(){
				var textarea_val=textarea.val();
				if(textarea[0].value==''){
					zishu.text("0");
				}else{
					var reg = /[\u4e00-\u9fa5\w]/g;
					if(textarea_val.match(reg).length>100){
						textarea_val=area_val;
					}else{
						area_val=textarea_val;
						zishu.text(area_val.length);
					}
				}
			});
	})		
	/*弹窗部分js代码*/
	
	
	
})();